$('.select2').select2();
// $.get("header_menu.html",function(data){ $("#header").html(data); });
$.get("footer.html",function(data){ $("#footer").html(data); });

$(document).ready(function () {
    // $("#vip").addClass("active");
    // $("#vip1").addClass("active");

    getData1(1);
  $('.search_btn').click(function () {
      $('.table_data').html('');
      pageDivd(0,0);
      getData1(1);
  });

    function pageDivd(curr,page_num){
        layui.use(['laypage', 'layer'], function(){
            var laypage = layui.laypage
                ,layer = layui.layer;
            laypage.render({
                elem: 'demo7'
                ,count: page_num
                ,limit:10
                ,curr:curr
                ,jump: function(obj,first){
                    if(!first){
                        getData1(obj.curr);

                    }
                }
            });
        })
    }
    function getData1(curr){
        var phone = $('#num_text').val();
        var status = $('#event_kind').val();
        $.ajax({
            type:"get",
            url:"http://114.116.72.220:9999/UserVip",
            async:true,
            data:{
                page:curr ,
                row: 10,
                phone:phone,
                status:status
            },
            success:function(data){
                // console.log(data);
                if(data[0] == 'failure'){
                    layer.msg('暂无数据');
                    return;
                }
                TableView(data[0]);
                pageDivd(curr,data[1]);
            }
        });
    }
    function TableView(data){
        $('.table_data').html('');

        for (var i=0;i<data.length;i++) {
            var trText = `<tr num="${data[i].order_id}"  class="${i%2 ? '' : 'tr_back'}">
		      		            <td>${i+1}</td>
		      		    		<td>${data[i].order_id}</td>
		      		    		<td>${data[i].phone}</td>

		      		    		<td>
		      		    			${data[i].money}
		      		    		</td>
		      		    		<td>
		      		    			${data[i].pay_way}
		      		    		</td>

		      		    		<td>${data[i].time}</td>
		      		    		<td>${data[i].type}</td>

		      		    	</tr>
		      		    	`;

            $('.table_data').append(trText) ;

        }
    }
});


